package main.java.learning.directory.Work.排序.Ac;

/**
 * @author aichao
 * @date 2021/2/23
 */
public class SelectSortDay4 {
    public static void main(String[] args) {
        int[] arrSelectSort = {49, 38, 65, 97, 23, 22, 76, 1};
        selectSort(arrSelectSort);
        for (int i : arrSelectSort) {
            System.out.println(i + "\t");
        }
    }
    public static void selectSort(int[] arr){
        int length = arr.length;
        for (int i = 0; i <length ; i++) {
            int indexMin = i;
            for (int j = i+1; j <length; j++) {
                if(arr[j]<arr[indexMin]){
                    indexMin=j;
                }
            }
            int tmp = arr[i];
            arr[i]=arr[indexMin];
            arr[indexMin]=tmp;
        }
    }
}
